/*!
 * \file RequestHandler.h
 * \brief
 */

#ifndef REQUEST_HANDLER_H
#define REQUEST_HANDLER_H

#include "Message.h"


namespace tsc
{
namespace common
{

enum requestToQueue_e
{
  REQUEST_IS_ON_QUEUE = 0,
  REQUEST_INCOMPLETE,
  REQUEST_ERROR
};

enum replyFromQueue_e
{
  REPLY_QUEUE_IS_EMPTY = 0,
  REPLY_PRESENT,
  REPLY_ERROR
};

class RequestHandler
{
public:
  RequestHandler();
  ~RequestHandler();

  requestToQueue_e putRequestOnInQueue(Message*& aMessageP);
  requestToQueue_e putRequestOnOutQueue(Message*& aMessageP);

  replyFromQueue_e getReplyFromInQueue(Message*& aMessageP,
                                       unsigned int aConnectionId = 0);
  replyFromQueue_e getReplyFromOutQueue(Message*& aMessageP,
                                        unsigned int aConnectionId = 0);

  // returns a TimerId needed to cancel the timer
  unsigned int startTimer(Message*& aMessageP,
                          unsigned long aTimeout);
  void timerExpired(unsigned int aTimerId);
  void cancelTimer(unsigned int aTimerId);

protected:

private:

};

} // namespace common
} // namespace tsc

#endif // REQUEST_HANDLER_H
